]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Special-case dropping over page indicators
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 29 Jun 2022 17:25:47 +0000 (14:25 -0300)
committerMarge Bot <marge-bot@gnome.org>
Wed, 10 Aug 2022 15:16:36 +0000 (15:16 +0000)
This brings back the ability to drop an icon beyong the last page.
Because the acceptDrop() method does not have access to the target
drop actor, to avoid an extra pick or manually calculating it from
allocations, simply store it during DragMonitor.dragDrop(), and
use the target actor in acceptDrop().

This commit also removes the last usage of SidePages, so drop the
enum too.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2335>

js/ui/appDisplay.js

index cc7881c6e1f555c29c814f62e4cb9485ebbd8b7e..1b21f14dc846c9f16da2117c428f03e8514b23a8 100644 (file)
@@ -79,13 +79,6 @@ const DEFAULT_FOLDERS = {
     },
 };
 
-var SidePages = {
-    NONE: 0,
-    PREVIOUS: 1 << 0,
-    NEXT: 1 << 1,
-    DND: 1 << 2,
-};
-
 function _getCategories(info) {
     let categoriesStr = info.get_categories();
     if (!categoriesStr)
@@ -884,6 +877,7 @@ var BaseAppView = GObject.registerClass({
     _onDragBegin() {
         this._dragMonitor = {
             dragMotion: this._onDragMotion.bind(this),
+            dragDrop: this._onDragDrop.bind(this),
         };
         DND.addDragMonitor(this._dragMonitor);
         this._appGridLayout.showPageIndicators();
@@ -908,6 +902,13 @@ var BaseAppView = GObject.registerClass({
         return DND.DragMotionResult.CONTINUE;
     }
 
+    _onDragDrop(dropEvent) {
+        // Because acceptDrop() does not receive the target actor, store it
+        // here and use this value in the acceptDrop() implementation below.
+        this._dropTarget = dropEvent.targetActor;
+        return DND.DragMotionResult.CONTINUE;
+    }
+
     _onDragEnd() {
         if (this._dragMonitor) {
             DND.removeDragMonitor(this._dragMonitor);
@@ -939,11 +940,15 @@ var BaseAppView = GObject.registerClass({
     }
 
     acceptDrop(source) {
+        const dropTarget = this._dropTarget;
+        delete this._dropTarget;
+
         if (!this._canAccept(source))
             return false;
 
-        if (this._dropPage) {
-            const increment = this._dropPage === SidePages.NEXT ? 1 : -1;
+        if (dropTarget === this._prevPageIndicator ||
+            dropTarget === this._nextPageIndicator) {
+            const increment = dropTarget === this._prevPageIndicator ? -1 : 1;
             const { currentPage, nPages } = this._grid;
             const page = Math.min(currentPage + increment, nPages);
             const position = page < nPages ? -1 : 0;